/**
 * Created by nieyu on 2016/8/22.
 */
function CLASS_LIANDONG_YAO(array)
{
    //数组，联动的数据源
    this.array=array;
    this.indexName='';
    this.obj='';
    //设置子SELECT
    this.subSelectChange=function(selectName1,selectName2)
    {
        //try
        //{
        var obj1=document.all[selectName1];
        var obj2=document.all[selectName2];
        var objName=this.toString();
        var me=this;

        obj1.onchange=function()
        {

            me.optionChange(this.options[this.selectedIndex].value,obj2.id)
        }
    }
    //设置第一个SELECT
    // 参数：indexName指选中项,selectName指select的ID
    this.firstSelectChange=function(indexName,selectName)
    {
        this.obj=document.all[selectName];
        this.indexName=indexName;
        this.optionChange(this.indexName,this.obj.id)
    }



    window.onload = function(){
        function immediately(){
           var href = location.href;
            var str = "grade=";
            var arr = href.split("=");
            if(str.indexOf(href) !=-1){

            }
            var grade =  arr[1].substring(4,0)
            for(var i = 0;i<document.getElementById("s1").children.length;i++){

                var op = document.getElementById("s1").children[i].value;
                if(op == grade){
                   document.getElementById("s1").value = op
                }


            }
        }
        immediately();
    }




    // indexName指选中项,selectName指select的ID
    this.optionChange=function (indexName,selectName)
    {
        var obj1=document.all[selectName];
        var me=this;
        obj1.length= 0;
        obj1.options[0]=new Option("请选择",'');
        for(var i=0;i<this.array.length;i++)
        {
            if(this.array[i][1]==indexName)
            {
                //alert(this.array[i][1]+" "+indexName);
                obj1.options[obj1.length]=new Option(this.array[i][2],this.array[i][0]);
            }
        }
    }

}
var array=new Array();
array[0]=new Array("2013","根目录","2013"); //数据格式 ID，父级ID，名称
array[1]=new Array("2014","根目录","2014");
array[2]=new Array("2015","根目录","2015");
array[3]=new Array("2016","根目录","2016");
array[4]=new Array("2017","根目录","2017");
array[5]=new Array("2018","根目录","2018");

array[6]=new Array("信息与工程系","2013","信息与工程系");
array[7]=new Array("城市学院","2013","城市学院");
array[8]=new Array("工商系","2013","工商系");
array[9]=new Array("酒店管理学院","2013","酒店管理学院");
array[10]=new Array("旅游系","2013","旅游系");
array[11]=new Array("烹饪学院","2013","烹饪学院");
array[12]=new Array("食品学院","2013","食品学院");
array[13]=new Array("外语系","2013","外语系");
array[14]=new Array("乡村建设与规划系","2013","乡村建设与规划系");
array[15]=new Array("艺术系","2013","艺术系");
array[16]=new Array("运动与休闲学院","2013","运动与休闲学院");

array[17]=new Array("信息与工程系","2014","信息与工程系");
array[18]=new Array("城市学院","2014","城市学院");
array[19]=new Array("工商系","2014","工商系");
array[20]=new Array("酒店管理学院","2014","酒店管理学院");
array[21]=new Array("旅游系","2014","旅游系");
array[22]=new Array("烹饪学院","2014","烹饪学院");
array[23]=new Array("食品学院","2014","食品学院");
array[24]=new Array("外语系","2014","外语系");
array[25]=new Array("乡村建设与规划系","2014","乡村建设与规划系");
array[26]=new Array("艺术系","2014","艺术系");
array[27]=new Array("运动与休闲学院","2014","运动与休闲学院");

array[28]=new Array("信息与工程系","2015","信息与工程系");
array[29]=new Array("城市学院","2015","城市学院");
array[30]=new Array("工商系","2015","工商系");
array[31]=new Array("酒店管理学院","2015","酒店管理学院");
array[32]=new Array("旅游系","2015","旅游系");
array[33]=new Array("烹饪学院","2015","烹饪学院");
array[34]=new Array("食品学院","2015","食品学院");
array[35]=new Array("外语系","2015","外语系");
array[36]=new Array("艺术系","2015","艺术系");
array[37]=new Array("运动与休闲学院","2015","运动与休闲学院");

array[38]=new Array("财务信息管理","工商系","财务信息管理");
array[39]=new Array("财务信息管理（对口）","工商系","财务信息管理（对口）");
array[40]=new Array("房地产经营与估价","工商系","房地产经营与估价");
array[41]=new Array("工商企业管理","工商系","工商企业管理");
array[42]=new Array("物流管理","工商系","物流管理");
array[43]=new Array("会计学","工商系","会计学");
array[44]=new Array("物流工程","工商系","物流工程");

array[45]=new Array("汽车检测与维修技术","城市学院","汽车检测与维修技术");

array[46]=new Array("酒店管理","酒店管理学院","酒店管理");
array[47]=new Array("酒店管理（对口）","酒店管理学院","酒店管理（对口）");
array[48]=new Array("酒店管理（转录）","酒店管理学院","酒店管理（转录）");
array[49]=new Array("酒店管理（高职）","酒店管理学院","酒店管理（高职）");
array[50]=new Array("人力资源管理","酒店管理学院","人力资源管理");

array[51]=new Array("信息与工程系","2016","信息与工程系");
array[52]=new Array("工商系","2016","工商系");
array[53]=new Array("酒店管理学院","2016","酒店管理学院");
array[54]=new Array("旅游系","2016","旅游系");
array[55]=new Array("烹饪学院","2016","烹饪学院");
array[56]=new Array("食品学院","2016","食品学院");
array[57]=new Array("外语系","2016","外语系");
array[58]=new Array("艺术系","2016","艺术系");
array[59]=new Array("运动与休闲学院","2016","运动与休闲学院");

array[60]=new Array("2019","根目录","2019");

array[61]=new Array("导游","旅游系","导游");
array[62]=new Array("会展策划与管理","旅游系","会展策划与管理");
array[63]=new Array("旅游管理","旅游系","旅游管理");
array[64]=new Array("旅游管理（对口）","旅游系","旅游管理（对口）");
array[65]=new Array("旅游管理（高职）","旅游系","旅游管理（高职）");
array[66]=new Array("涉外旅游","旅游系","涉外旅游");
array[67]=new Array("涉外旅游（转录）","旅游系","涉外旅游（转录）");
array[68]=new Array("会展经济与管理","旅游系","会展经济与管理");

array[69]=new Array("烹饪工艺与营养","烹饪学院","烹饪工艺与营养");
array[70]=new Array("烹饪工艺与营养（对口）","烹饪学院","烹饪工艺与营养（对口）");
array[71]=new Array("烹饪工艺与营养（转录）","烹饪学院","烹饪工艺与营养（转录）");
array[72]=new Array("烹饪与营养教育","烹饪学院","烹饪与营养教育");
array[73]=new Array("烹饪与营养教育（对口）","烹饪学院","烹饪与营养教育（对口）");
array[74]=new Array("烹饪与营养教育（高职）","烹饪学院","烹饪与营养教育（高职）");
array[75]=new Array("中西面点工艺","烹饪学院","中西面点工艺");

array[76]=new Array("食品科学与工程","食品学院","食品科学与工程");
array[77]=new Array("食品质量与安全","食品学院","食品质量与安全");
array[78]=new Array("西餐工艺","食品学院","西餐工艺");
array[79]=new Array("西餐工艺（对口）","食品学院","西餐工艺（对口）");
array[80]=new Array("西餐工艺（A）","食品学院","西餐工艺（A）");
array[81]=new Array("西餐工艺（B）","食品学院","西餐工艺（B）");

array[82]=new Array("商务英语","外语系","商务英语");
array[83]=new Array("旅游英语","外语系","旅游英语");
array[84]=new Array("旅游英语（转录）","外语系","旅游英语（转录）");
array[85]=new Array("商务日语","外语系","商务日语");
array[86]=new Array("应用法语","外语系","应用法语");
array[87]=new Array("日语","外语系","日语");

array[88]=new Array("园林工程技术","乡村建设与规划系","园林工程技术");

array[89]=new Array("信息管理与信息系统","信息与工程系","信息管理与信息系统");
array[90]=new Array("信息管理与信息系统（A）","信息与工程系","信息管理与信息系统（A）");
array[91]=new Array("信息管理与信息系统（B）","信息与工程系","信息管理与信息系统（B）");
array[92]=new Array("电子商务","信息与工程系","电子商务");
array[93]=new Array("电子商务（对口）","信息与工程系","电子商务（对口）");
array[94]=new Array("电子商务（转录）","信息与工程系","电子商务（转录）");
array[95]=new Array("计算机信息管理","信息与工程系","计算机信息管理");
array[96]=new Array("计算机信息管理（对口）","信息与工程系","计算机信息管理（对口）");
array[97]=new Array("楼宇智能化工程技术","信息与工程系","楼宇智能化工程技术");
array[98]=new Array("楼宇智能化工程技术（对口）","信息与工程系","楼宇智能化工程技术（对口）");
array[99]=new Array("数字媒体技术","信息与工程系","数字媒体技术");
array[100]=new Array("建筑电气与智能化","信息与工程系","建筑电气与智能化");

array[101]=new Array("环境设计","艺术系","环境设计");
array[102]=new Array("人物形象设计","艺术系","人物形象设计");
array[103]=new Array("装潢艺术设计","艺术系","装潢艺术设计");
array[104]=new Array("风景园林","艺术系","风景园林");
array[105]=new Array("园林工程技术","艺术系","园林工程技术");

array[106]=new Array("高尔夫服务与管理","运动与休闲学院","高尔夫服务与管理");
array[107]=new Array("休闲体育","运动与休闲学院","休闲体育");
array[108]=new Array("运动休闲服务与管理","运动与休闲学院","运动休闲服务与管理");

//--------------------------------------------
//这是调用代码
var liandong=new CLASS_LIANDONG_YAO(array) //设置数据源
liandong.firstSelectChange("根目录","s1"); //设置第一个选择框
liandong.subSelectChange("s1","s2"); //设置子级选择框
liandong.subSelectChange("s2","s3");